package com.j.lemon.learn.thread;

/**
 * @Author lijunjun
 * @Date 2019-03-18 10:47
 * @Description
 */
public class NotVisibility {
    private static volatile boolean flag;
    private static int number;

    private static class ReadThread extends Thread{

        @Override
        public void run() {
            while (!flag){
                Thread.yield();
            }
            System.out.println(number);
        }
    }

    public static void main(String[] args) {
        new ReadThread().start();
        flag=false;
        number=42;
    }
}
